{% extends "base.html" %}
{% block header %}
<script type="text/javascript">
function delete_server(server_id){
    $.get('/vps/delete/'+server_id,{},function(d){
        $("#sp_"+server_id).html("<img src='/static/img/loading.gif'/>");
        if(d.r){
            setTimeout(function(){
                location.reload();
                    },10000
            );
        }
    });
}
</script>
{% endblock %}
{% block content %}
   <table class="table">
       <thead>
            <tr>
                <td>主机名</td>
                <td>操作</td>
            </tr>
       </thead>
       <tbody>
           {% for server in servers %}
           <tr>
               <td>{{ server.name }}</td>
               <td>
                   <a href="/vps/server/{{ server.id }}" class="btn btn-primary">查看</a>
                   &nbsp;&nbsp;&nbsp;&nbsp;
                   <a href="javascript:void(0);" onclick="delete_server('{{ server.id }}')" class="btn btn-danger">删除</a>
                   <span id="sp_{{ server.id }}"></span>
               </td>
           </tr>
           {% endfor %}
       </tbody>
   </table>
{% endblock %}